package com.luoying.itew.util;

import androidx.annotation.Nullable;

import com.orhanobut.logger.AndroidLogAdapter;
import com.orhanobut.logger.FormatStrategy;
import com.orhanobut.logger.Logger;
import com.orhanobut.logger.PrettyFormatStrategy;

public class LogUtils {
    private static final String TAG = "AnTai";

    private LogUtils (){}
    /**
     * 初始化log工具，在app入口处调用
     * @param isLogEnable 是否打印log
     */
    public static void init(final boolean isLogEnable) {
        FormatStrategy formatStrategy = PrettyFormatStrategy.newBuilder()
                .showThreadInfo(false)
                .methodCount(0)
                .methodOffset(6)
                .tag("TAG")
                .build();
        Logger.addLogAdapter(new AndroidLogAdapter(formatStrategy){
            @Override
            public boolean isLoggable(int priority, @Nullable String tag) {
                return isLogEnable;
            }
        });
    }


    public static void d(String message) {
        d(TAG, message);
    }

    public static void d(String tag, String message) {
        Logger.t(tag).d(message);
    }

    public static void i(String message) {
        i(TAG, message);
    }

    public static void i(String tag, String message) {
        Logger.t(tag).i(message);
    }

    public static void w(String message) {
        w(TAG, message);
    }

    public static void w(String tag, String message) {
        Logger.t(tag).w(message);
    }

    public static void e(String message) {
        e(TAG, message);
    }

    public static void e(String tag, String message) {
        Logger.t(tag).e(message);
    }

}
